package com.blt.car.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.blt.car.R;
import com.blt.car.utils.Uiutils;

import blt.app_core.api.base.CoreManager;
import blt.app_core.api.purse.PayApi;

/**
 * Created by xgp on 2017/6/28.
 */

public class TakeCashDialog extends Dialog {

    private Button submit;
    private EditText input;

    public TakeCashDialog(Context context) {
        super(context, R.style.CommonDialog);
        setCancelable(false);
        setCanceledOnTouchOutside(true);
    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);  //此处可以设置dialog显示的位置
        window.setWindowAnimations(R.style.Dialog_Anim);  //添加动画

        WindowManager.LayoutParams params = window
                .getAttributes();
        params.width = Uiutils.dip2px(252);
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_getcash);

        ImageView ivCancle = (ImageView) this.findViewById(R.id.iv_cancle);
        ivCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

        input = (EditText) findViewById(R.id.dialog_extract_input);
        submit = (Button) findViewById(R.id.dialog_extract_submit);

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String amount = input.getText().toString();
                CoreManager.getCore(PayApi.class).extractMoney(amount);
                dismiss();
            }
        });
    }
}
